import java.util.ArrayList;

import java.util.Iterator;


/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-06-30
 * Time: 21:22
 */
public class Test1 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();

        list.add("aaa");
        list.add("bbb");
        list.add("ccc");

        //获取迭代器对象
        Iterator<String> it = list.iterator();

        while (it.hasNext()) {//判断当前位置是否有元素
            String str = it.next();//1.获取当前位置 2.将迭代器指针指向下一个元素
            if (str.equals("bbb")) {
                list.remove("bbb");
            }
            System.out.println(str);
        }

        System.out.println(list);
    }
}
